package com.gkzf.ai.module.crm.util.assembly;

import com.alibaba.fastjson.JSONObject;
import com.gkzf.ai.module.crm.controller.admin.creditReport.vo.creditreportdetails.CreditReportDetailsSaveReqVO;

import java.util.Map;

public class PublicInformationSummary {

    private static final String  PUBLIC_INFO_OVERVIEW = "公共信息概要";

    private static final String  PUBLIC_INFO_SUMMARY = "公共信息汇总";

    private static final String  ADMINISTRATIVE_PENALTY_INFO = "行政处罚信息";

    private static final String  TAX_ARREARS_INFO = "欠税信息";

    private static final String  CIVIL_JUDGMENT_INFO = "民事判决信息";

    private static final String  ENFORCEMENT_INFO = "强制执行信息";

    private static final String   RECORDS_NUMBER = "记录数";

    public static final String INVOLVED_AMOUNT = "涉及金额";

    public void getPublicInformationSummary(Map<String, Object> param, CreditReportDetailsSaveReqVO creditReportDetailsSaveReqVO) {
        if (param.containsKey(PUBLIC_INFO_OVERVIEW)){
            JSONObject publicInfoOverview = (JSONObject)param.get(PUBLIC_INFO_OVERVIEW);
            if (publicInfoOverview.containsKey(PUBLIC_INFO_SUMMARY)) {
                JSONObject publicInfoSummary = (JSONObject)publicInfoOverview.get(PUBLIC_INFO_SUMMARY);
                if (null != publicInfoSummary && publicInfoSummary.containsKey(ADMINISTRATIVE_PENALTY_INFO)) {
                    JSONObject administrativePenaltyInfo = (JSONObject) publicInfoSummary.get(ADMINISTRATIVE_PENALTY_INFO);
                    creditReportDetailsSaveReqVO.setExecutivePenalizeInfoCount(AssembleUtils.getStringInteger(administrativePenaltyInfo, RECORDS_NUMBER));
                    creditReportDetailsSaveReqVO.setExecutivePenalizeInfoMoney(AssembleUtils.getBigDecimalValue(administrativePenaltyInfo, INVOLVED_AMOUNT));
                }
                if (null != publicInfoSummary && publicInfoSummary.containsKey(TAX_ARREARS_INFO)) {
                    JSONObject taxArrearsInfo = (JSONObject) publicInfoSummary.get(TAX_ARREARS_INFO);
                    creditReportDetailsSaveReqVO.setDebtInfoCount(AssembleUtils.getStringInteger(taxArrearsInfo, RECORDS_NUMBER));
                    creditReportDetailsSaveReqVO.setDebtInfoMoney(AssembleUtils.getBigDecimalValue(taxArrearsInfo, INVOLVED_AMOUNT));
                }
                if (null != publicInfoSummary && publicInfoSummary.containsKey(CIVIL_JUDGMENT_INFO)) {
                    JSONObject civilJudgmentInfo = (JSONObject) publicInfoSummary.get(CIVIL_JUDGMENT_INFO);
                    creditReportDetailsSaveReqVO.setCivilJudgmentInfoCount(AssembleUtils.getStringInteger(civilJudgmentInfo, RECORDS_NUMBER));
                    creditReportDetailsSaveReqVO.setCivilJudgmentInfoMoney(AssembleUtils.getBigDecimalValue(civilJudgmentInfo, INVOLVED_AMOUNT));
                }
                if (null != publicInfoSummary && publicInfoSummary.containsKey(ENFORCEMENT_INFO)) {
                    JSONObject civilJudgmentInfo = (JSONObject) publicInfoSummary.get(ENFORCEMENT_INFO);
                    creditReportDetailsSaveReqVO.setEnforceInfoCount(AssembleUtils.getStringInteger(civilJudgmentInfo, RECORDS_NUMBER));
                    creditReportDetailsSaveReqVO.setEnforceInfoMoney(AssembleUtils.getBigDecimalValue(civilJudgmentInfo, INVOLVED_AMOUNT));
                }
            }

        }
    }

}
